const DB = require('../db/db');

module.exports = {
    // 新增分院
    async add(branch) {
        let result = await DB.insert('branch', branch)
        if (result.affectedRows > 0) {
            return { msg: '分院新增成功', code: 0, data: result };
        }
    },
    // 删除分院
    async del(branch) {
        let result = await DB.del('branch', branch)
        return { msg: '分院删除成功', code: 0, data: result }
    },
    // 查询所有的分院
    async select() {
        let result = await DB.select('branch', {});
        return { msg: '查询成功', code: 0, data: result };
    },
    //更新
    async update(param) {
        let result = await DB.update('branch', {
            updateFields: {
                name: `"${param.name}"`,
                address: `"${param.address}"`
            },
            where_and: [`id=${param.id}`]
        });
        return { msg: '修改成功', code: 0, data: result };
    }
}